<template>
  <div class="testMangement">
    <el-table :highlight-current-row="true"
              border
              :header-cell-style="{ background: '#f5f5f5' }"
              :data="testList.list">
      <el-table-column type="index"
                       label="序号"
                       sortable
                       align="center"
                       width="80"
                       show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="exercise_name"
                       label="问卷名称"
                       align="center"
                       show-overflow-tooltip>
      </el-table-column>
      <el-table-column label="问卷分值"
                       prop="score"
                       align="center">
      </el-table-column>
      <el-table-column label="操作"
                       show-overflow-tooltip
                       align="center">
        <template slot-scope="scope">
          <el-button type="text"
                     @click="lookQuestion(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @current-change="handlePageChange"
                   @size-change="handleSizeChange"
                   :current-page="requestParam.page"
                   :page-size="requestParam.page_size"
                   layout="total,sizes,prev, pager, next, jumper"
                   background
                   :total="testList.total_count"
                   align="center">
    </el-pagination>
  </div>
</template>

<script>
import { backEvaluateApi } from '@/services/ProjectCenter'

export default {
  data () {
    return {
      testList: {
        list: [],
        total: 0,
        total_count: 0
      },
      requestParam: {
        comp_id: '',
        is_page: 1,
        page: 1,
        page_size: 10,
      }
    }
  },
  created () {
    this.requestParam.comp_id = JSON.parse(window.localStorage.userInfo).comp_id// 公司id
    this.getTestList()
  },
  mounted () { },
  methods: {
    //查询
    getTestList () {
      backEvaluateApi.getTestList({
        params: this.requestParam
      }).then((res) => {
        if (res.code === 0) {
          let list=res.data.list||[];
          this.testList = res.data;
          if(list.length>0){
            this.testList.list=list.reverse();//根据产品需求根据位置颠倒一下
          }
        }
      }).catch(err => {
        console.log(err);
      })
    },
    //分页
    handlePageChange (val) {
      this.requestParam.page = val
      this.getTestList()
    },
    handleSizeChange (val) {
      this.requestParam.page_size = val
      this.getTestList()
    },
    //查看问卷
    lookQuestion (row) {
      this.$router.push({ path: '\checkCommonQuestionList', query: { types: "check", exerciseId: row.exercise_id, exerciseName: row.exercise_name } })
      // this.$router.push({ path: '\checkQuestionList1', query: { types: "check", exerciseId: row.exercise_id, exerciseName: row.exercise_name } })
    },
  },
  computed: {},
  watch: {}
}
</script>

<style lang="scss" scoped>
.testMangement {
  padding: 20px;
}
</style>
